var question_index=1;
var question_count=0;
$(function() {
    question_count=$('#question-count').val();
    $('.cancel').click(function(){
        $('.question-iframe', window.parent.document).animate({top:'100%'},500,function(){
            
        });
        $('.answer-iframe', window.parent.document).animate({top:'100%'},500,function(){
            
        });
        setTimeout(function(){
            $('.zhezhao', window.parent.document).hide();
        },499);
    });

    resetPageButton();
})


function toPrev(){
    if(question_index>1){
        var obj=$('.question-active');
        obj.prev().addClass('question-active');
        obj.removeClass('question-active');
        question_index--;
        resetPageButton();
    }
    
}

function toNext(){
    if(question_index<question_count){
        var obj=$('.question-active');
        obj.next().addClass('question-active');
        obj.removeClass('question-active');
        question_index++;
        resetPageButton();
    }
}

function resetPageButton(){
    $('.question-index').html(question_index);
    if(question_index==1){
        $('.page-prev').hide();
    }
    else{
        $('.page-prev').show();
    }
    if(question_index>=question_count){
        $('.page-next').hide();
    }
    else{
        $('.page-next').show();
    }
}